package com.bohua.base.thread;

import android.util.Log;

import com.bohua.HDJni.Jni485;

public class RS485ClientReciveThread extends Thread{
	
	public String input_485;
	public int[] ret;
	public void run()
	{
//		ret = new int[3001];
		
		Log.i("RS485ClientReciveThread","RS485ClientReciveThread");
//		while(true)
//		{
//
//			if(Jni485.retFlag() == 1) 
//			{
//				String test = Jni485.ret();
//				Log.i("RS485ClientReciveThread",test);
//				
//				
////				   int[] n = new int[test.length()]; 
//				   for(int i = 0;i<test.length();i++){
////				     ret[i] = Integer.parseInt(test.substring(i,i+1));
//				     Log.i("RS485ClientReciveThread","m ="+Integer.parseInt(test.substring(i,i+1)));
//				   }
//
////				for(int i=0;i<b.length;i++) 
////				{
//////					Log.i("RS485ClientReciveThread","m ="+Integer.toHexString(new Byte(b[i]).intValue()& 0xFF));
////					Log.i("RS485ClientReciveThread","m ="+b[i]);
////				}
////				char[] ia=new char[test.length()];
////				for(int i=0;i<test.length();i++)
////				{
////					int m = (int)test.toCharArray()[i]& 0xFF;
////					Log.i("RS485ClientReciveThread","m ="+Integer.toHexString(m));
////				}
////				
//			}
//				
//				
//				
////				for(int i = 0;i < 3000 ; i++)
////				{
////					ret[i] = Jni485.ret()[i];
//////					Log.i("RS485ClientReciveThread","m ="+Integer.toHexString(ret[i]));
////				}
////			}
//		}
		
		
		Log.i("RS485ClientReciveThread","RS485ClientReciveThread");
		while(true)
		{
			if(Jni485.retFlag() == 1) 
			{
				Log.i("RS485ClientReciveThread","retFlag = 1");
				int length = Jni485.retReadLength();
				Log.i("RS485ClientReciveThread","length = "+ length);
				int[] in = new int[length];
				byte[] out = new byte[length];
				in = Jni485.ret();
				for(int i=0;i<length;i++)
				{
					out[i] = (byte) in[i];
//					Log.i("RS485ClientReciveThread","m ="+Integer.toHexString(in[i]));
//					Log.i("RS485ClientReciveThread","m ="+out[i]);
				}
				RS485ClientSendThread.outPut(out);
			}
		}
	}
		
		
		
		
//		Log.i("RS485ClientReciveThread","RS485ClientReciveThread");
////		Jni485.read();
//		while(true)
//		{
////			Log.i("RS485ClientReciveThread","Jni485.ret");
//			input_485 = Jni485.ret();
//			if((input_485!=null)&&(input_485.length()!=0))
//			{
//				Log.i("RS485ClientReciveThread",input_485);
//				char[] xxxx = new char[3001];
//				xxxx = input_485.toCharArray();
////				int[] n = new int[input_485.length()]; 
//				for(int i=0;i<input_485.length();i++)
//				{
////					int m = (int)xxxx[i] & 0xFF;
//					Log.i("RS485ClientReciveThread","m ="+Integer.toHexString(xxxx[i]));
//				}
//				
//				Log.i("RS485ClientReciveThread","485 recive len = "+input_485.length());
//				RS485ClientSendThread.outPut(input_485);
//			}
//		}
//	}
	
//	public char[] input_485;
//	public int[] xxxx;
//	public void run()
//	{
//		Log.i("RS485ClientReciveThread","RS485ClientReciveThread");
////		Jni485.read();
//		input_485 = new char[3001];
//		xxxx = new int[3001];
//		while(true)
//		{
////			Log.i("RS485ClientReciveThread","Jni485.ret");
//			String str = Jni485.ret();
//			input_485 = str.toCharArray();
//			if((input_485!=null)&&(str.length()!=0))
//			{
////				Log.i("RS485ClientReciveThread",input_485);
////				Log.i("RS485ClientReciveThread",Integer.toHexString(input_485));
////				Log.i("RS485ClientReciveThread","485 recive len = "+input_485.length());
////				RS485ClientSendThread.outPut(input_485);
//				
//				for(int i=0;i<str.length();i++)
//				{
//					int m = input_485[i] & 0xFF;  
//					xxxx[i] = (int)m;
//					Log.i("RS485ClientSendThread222",Integer.toHexString(m));
//				}
//				String out = xxxx.toString();
//				RS485ClientSendThread.outPut(out);
//			}
//		}
//	}
	
	
	
	
}
